package com.gem.shop.dao.impl;

import com.gem.shop.dao.OrderDao;
import com.gem.shop.entity.Order;
import com.gem.shop.util.HibernateTemplate;

import java.util.List;

/**
 * @author zhang
 * @date 2020/10/3 14:26
 */
public class OrderDaoImpl implements OrderDao {

    @Override
    public void insertOrder(Order order) {
        HibernateTemplate.execute(ses -> ses.save(order));
    }

    @Override
    public List<Order> selectOrderByCustomerId(Integer id) {
        return (List<Order>) HibernateTemplate.execute(ses -> ses.createQuery("from Order where customer.id = :id order by id desc").setParameter("id",id).list());
    }
}
